import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from "@/views/LoginView";
// import DoctorList from "../components/doctor/DoctorList.vue"

Vue.use(VueRouter)

const routes = [{
    path: '/',
    name: 'login',
    component: LoginView
},
    {
        path: '/firstMenu',
        name: 'firstMenu',
        component: () => import('../views/FirstMenu.vue'),
        children: [{
            path: '/hospital',
            name: 'hospital',
            component: () => import('../views/HospitalView.vue'),
        }, 
        {
            path: '/doctor',
            name: 'doctor',
            component: () => import('../views/DoctorView.vue'),
        },
         {
            path: '/patient',
            name: 'patient',
            component: () => import('../views/PatientView.vue'),
        }, {
            path: '/patientcaser',
            name: 'patientcaser',
            component: () => import('../components/patient/Patientcase'),
        }, {
            path: '/clinicActivity',
            name: 'clinicActivity',
            component: () => import('../views/ClinicActivityView.vue'),
        }, {
            path: '/discussion',
            name: 'discussion',
            component: () => import('../views/DiscussionView.vue'),
        }, {
            path: '/trade',
            name: 'trade',
            component: () => import('../views/TradeView.vue'),
        }, {
            path: '/banner',
            name: 'banner',
            component: () => import('../views/BannerView.vue'),
        },
        {
            path: '/doctorlist',
            name: 'doctorlist',
            component: () => import('../components/doctor/DoctorList'),
        },

            {
                path: '/addHospital',
                name: 'addHospital',
                component: () => import('../components/hospital/AddHospital'),
            },
            {
                path: '/checkHospital',
                name: 'checkHospital',
                component: () => import('../components/hospital/CheckHospital'),
            }, {
                path: '/addDoctor',
                name: 'addDoctor',
                component: () => import('../components/doctor/AddDoctor'),
            },
            {
                path: '/checkdoctor',
                name: 'checkdoctor',
                component: () =>
                    import('../views/CheckDoctorView.vue'),
            }, {
                path: '/yupeiyang',
                name: 'yupeiyang',
                component: () => import('../views/YuPeiYang.vue'),
            },
            

            {
                path: '/checkdiscussion',
                name: 'CheckDiscussion',
                component: () =>
                    import('../views/CheckDiscussion.vue'),
            },
            {
                path: '/illnesslog',
                name: 'illnesslog',
                component: () => import('../components/Check the patient/IllnessLog.vue')
            },
            {
                path: '/fazuocishu',
                name: 'FaZuojilu',
                component: () => import('../components/fazuocishu.vue')
            },
            {
                path: '/zhengzhuangjilu',
                name: 'Zhangzhuangjilu',
                component: () => import('../components/Zhengzhuangjilu.vue')
            },
            {
                path: '/chakan',
                name: 'ChaKan',
                component: () => import('../views/ChaKanRiZhi.vue')
            }, {
                path: '/updateHospital',
                name: 'updateHospital',
                component: () => import('../components/hospital/UpdateHospital')
            }, {
                path: '/role',
                name: 'role',
                component: () => import('../components/role/RoleList')
            },{
                path: '/checkclinicactivitylist',
                name: 'checkclinicactivitylist',
                component: () => import('../components/clinicActivity/CheckClinicActivityList'),
            },
            {
                path: '/clinicactivitylist',
                name: 'clinicactivitylist',
                component: () => import('../components/clinicActivity/ClinicActivityList'),
            },
            
        ]
    }
]

const router = new VueRouter({
    routes
})
//前置守卫
router.beforeEach((to, from, next) => {//路由跳转中
    if (to.path == "/") {
        next();
    } else {
        if (window.localStorage.getItem("loginUserInfo")) {
            next()
        } else {
            next({path: '/'})
        }
    }
})
export default router
